import Vue from 'vue';
import App from './App.vue';
import router from './router';
import store from './store';

Vue.config.productionTip = false;
import './assets/element.js';
import '../src/assets/css/cssreset.css';
import axios from 'axios';
import './assets/font/iconfont.css';
import eIconPicker from 'e-icon-picker';
import 'e-icon-picker/lib/symbol.js'; //基本彩色图标库
import 'e-icon-picker/lib/index.css'; // 基本样式，包含基本图标
import 'font-awesome/css/font-awesome.min.css'; //font-awesome 图标库
import 'element-ui/lib/theme-chalk/icon.css'; //element-ui 图标库

//全局删除增加图标
Vue.use(eIconPicker, {
	FontAwesome: true,
	ElementUI: true,
	eIcon: true, //自带的图标，来自阿里妈妈
	eIconSymbol: true, //是否开启彩色图标
	addIconList: [],
	removeIconList: [],
	zIndex: 3100 //选择器弹层的最低层,全局配置
});

axios.defaults.baseURL = 'https://jumeng.xzjumeng.com/prod-api';
axios.interceptors.request.use(
	(config) => {
		// 判断是否存在token，如果存在的话，则每个http header都加上token
		config.withCredentials = true;
		if (sessionStorage.getItem('token')) {
			config.headers['authorization'] = 'Bearer ' + sessionStorage.getItem('token');
		}
		return config;
	},
	(err) => {
		return Promise.reject(err);
	}
);

Vue.prototype.$axios = axios;
new Vue({
	router,
	store,
	render: (h) => h(App)
}).$mount('#app');
